24 |
25 |
26 |
27 |
28 |
$filename
29 |
30 |
31 |
32 | #if (!$error.isEmpty())
33 |
34 |
35 |
36 |
$error
37 |
38 |
39 |
40 | #else
41 |
42 |
43 |
44 |
45 |
46 | #foreach($line in $file)
47 | $line
48 | #end
49 |
50 |
51 |
52 |
53 | #end
54 |
55 | #parse("templates/footer.vm")
56 |
57 |
58 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/services/devtest/DevTestService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.services.devtest;
17 |
18 | import com.rhythm.louie.Service;
19 |
20 | /**
21 | *
22 | * @author cjohnson
23 | */
24 | @Service
25 | public interface DevTestService {
26 | final String SERVICE_NAME = "devtest";
27 |
28 | /**
29 | * Generates a message using the configured JMS adapter,
30 | * and the same delegate should receive that message
31 | *
32 | * @param message
33 | * @return
34 | * @throws Exception
35 | */
36 | public String messageTest(String message) throws Exception;
37 |
38 | /**
39 | * Test sending an email
40 | * @param sender
41 | * @param receiver
42 | * @param subject
43 | * @param body
44 | * @return
45 | * @throws Exception
46 | */
47 | public Boolean sendEmail(String sender, String receiver, String subject, String body) throws Exception;
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/server/CustomProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.server;
17 |
18 | import java.util.HashMap;
19 | import java.util.Map;
20 |
21 | /**
22 | *
23 | * @author eyasukoc
24 | */
25 | public class CustomProperty {
26 |
27 | private final String name;
28 | private final Map
properties;
29 |
30 | public CustomProperty(String name) {
31 | this.name = name;
32 | properties = new HashMap<>();
33 | }
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public void setProperty(String key, String value){
40 | properties.put(key, value);
41 | }
42 |
43 | public String getProperty(String key) {
44 | return properties.get(key);
45 | }
46 |
47 | public String getProperty(String key, String def) {
48 | String value = properties.get(key);
49 | if (value == null) return def;
50 | return value;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/site/apt/manual/start/create.apt:
--------------------------------------------------------------------------------
1 | ------
2 | Creating a project
3 | ------
4 |
5 | Creating a new Louie project
6 |
7 | * From the command line:
8 |
9 | +-----+
10 | mvn archetype:generate -DarchetypeGroupId='com.rhythm.louie' -DarchetypeArtifactId='louie-archetype' -DarchetypeVersion='1.12'
11 |
12 | Define value for property 'groupId': : com.somecompany
13 | Define value for property 'artifactId': : sample
14 | Define value for property 'version': 1.0-SNAPSHOT: :
15 | Define value for property 'package': com.somecompany: :
16 | Define value for property 'service_lowercase': : : sample
17 | Define value for property 'service_titlecase': : : Sample
18 |
19 | +-----+
20 |
21 | * OR From NetBeans:
22 |
23 |
24 | [../../images/create/nb_new.png]
25 |
26 | <>
27 |
28 | [../../images/create/nb_from_arch.png]
29 |
30 | <>
31 |
32 | [../../images/create/nb_arch_filter.png]
33 |
34 | <>
35 |
36 | [../../images/create/nb_arch_args.png]
37 |
38 | <>
39 |
40 | [../../images/create/nb_generated.png]
41 |
42 | <>
43 |
44 | [../../images/create/nb_clean_build.png]
45 |
46 | <>
47 |
48 | Congratulations! Your first project is now created and compiled.
49 | Next you can {{{./addserver.html}add}} a GlassFish server to your NetBeans and then {{{./run.html}run}} the project!
50 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/jdbc/MysqlConnectionFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.jdbc;
17 |
18 | import java.sql.Connection;
19 | import java.sql.DriverManager;
20 |
21 | /**
22 | *
23 | * @author cjohnson
24 | */
25 | public class MysqlConnectionFactory implements ConnectionFactory {
26 | private final String host;
27 | private final String db;
28 | private final String user;
29 | private final String pw;
30 |
31 | public MysqlConnectionFactory(String host, String db) {
32 | this (host,db,"","");
33 | }
34 |
35 | public MysqlConnectionFactory(String host, String db, String user, String pw) {
36 | this.host = host;
37 | this.db = db;
38 | this.user = user;
39 | this.pw = pw;
40 | }
41 |
42 | @Override
43 | public Connection createConnection() throws Exception {
44 | Class.forName("com.mysql.jdbc.Driver");
45 | return DriverManager.getConnection("jdbc:mysql://"+host+"/"+db,user,pw);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/engine/src/main/resources/config/louie-internal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 8080
9 | louie
10 | false
11 |
12 |
13 | true
14 | false
15 | true
16 |
17 |
18 |
19 | true
20 | com.rhythm.louie.services.info.InfoServiceFactory
21 |
22 |
23 | true
24 | com.rhythm.louie.services.auth.AuthServiceFactory
25 |
26 |
27 | true
28 | com.rhythm.louie.services.status.StatusServiceFactory
29 |
30 |
31 |
32 |
33 |
34 | 8
35 |
36 |
37 |
38 | %
39 |
40 |
41 |
--------------------------------------------------------------------------------
/web/src/main/java/com/rhythm/louie/servlet/ServiceRegister.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.servlet;
17 |
18 | import com.rhythm.louie.server.ServiceManager;
19 |
20 | import javax.servlet.ServletContextEvent;
21 | import javax.servlet.ServletContextListener;
22 | import javax.servlet.annotation.WebListener;
23 |
24 | import org.slf4j.LoggerFactory;
25 |
26 | /**
27 | * Web application lifecycle listener.
28 | * @author cjohnson
29 | */
30 | @WebListener()
31 | public class ServiceRegister implements ServletContextListener {
32 |
33 | @Override
34 | public void contextInitialized(ServletContextEvent sce) {
35 | try {
36 | ServiceManager.initialize(sce.getServletContext());
37 | } catch (Exception ex) {
38 | LoggerFactory.getLogger(ServiceRegister.class)
39 | .error("Error Initializing Services", ex);
40 | }
41 | }
42 |
43 | @Override
44 | public void contextDestroyed(ServletContextEvent sce) {
45 | ServiceManager.shutdown();
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/cache/GuavaCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.cache;
17 |
18 | import com.google.common.cache.CacheStats;
19 | import com.google.common.collect.ImmutableMap;
20 |
21 | import java.util.concurrent.Callable;
22 | import java.util.concurrent.ConcurrentMap;
23 | import java.util.concurrent.ExecutionException;
24 |
25 | /**
26 | * I hate that this exists.
27 | * It is done specifically so that the manager can handle it, and also so that
28 | * we can present an EMPTY cache if caching is disabled
29 | * @author eyasukoc
30 | */
31 | public interface GuavaCache extends Cache {
32 |
33 | com.google.common.cache.Cache getGuava();
34 |
35 | V get(K key, Callable extends V> valueLoader);
36 |
37 | V getIfPresent(K key);
38 |
39 | void refresh(K key);
40 |
41 | void cleanUp();
42 |
43 | ConcurrentMap asMap();
44 |
45 | ImmutableMap getAllPresent(Iterable> keys);
46 |
47 | CacheStats getStats();
48 |
49 | ImmutableMap getAll(Iterable extends K> keys) throws ExecutionException;
50 | }
51 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/connection/LouieConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.connection;
17 |
18 | import com.google.protobuf.Message;
19 |
20 | import com.rhythm.pb.RequestProtos.IdentityPB;
21 | import com.rhythm.pb.RequestProtos.SessionKey;
22 |
23 | import java.net.URLConnection;
24 |
25 | /**
26 | *
27 | * @author cjohnson
28 | */
29 | public interface LouieConnection {
30 |
31 | IdentityPB getIdentity();
32 |
33 | SessionKey getSessionKey() throws Exception;
34 |
35 | Response request(Request req) throws Exception;
36 |
37 | void setMaxTimeout(int seconds);
38 |
39 | int getMaxTimeout();
40 |
41 | void setRetryEnable(boolean enable);
42 |
43 | boolean getRetryEnable();
44 |
45 | void enableAuthPort(boolean enable);
46 |
47 | void setGateway(String gateway);
48 |
49 | String getGateway();
50 |
51 | void setPort(int port);
52 |
53 | URLConnection getJsonForwardingConnection() throws Exception;
54 |
55 | URLConnection getForwardingConnection() throws Exception;
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/archetype/src/main/resources/archetype-resources/server/assembly/python.xml:
--------------------------------------------------------------------------------
1 | #set( $symbol_pound = '#' )
2 | #set( $symbol_dollar = '$' )
3 | #set( $symbol_escape = '\' )
4 |
5 |
12 |
13 | python
14 | false
15 |
16 | zip
17 |
18 |
19 |
20 | true
21 | /
22 | src/main/python
23 |
24 |
25 | true
26 | /
27 | target/generated-sources/python
28 |
29 | **/*.py
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | true
38 |
39 | ${groupId}:${rootArtifactId}-service:zip:python:*
40 |
41 | /
42 |
43 |
44 | true
45 |
46 | com.rhythm.louie:louie:zip:python:*
47 |
48 | /
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/jdbc/DBUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.jdbc;
17 |
18 | import java.sql.PreparedStatement;
19 | import java.sql.SQLException;
20 | import java.sql.Types;
21 |
22 |
23 | /**
24 | * @author cjohnson
25 | * Created: Sep 2, 2011 11:23:21 AM
26 | */
27 | public class DBUtils {
28 | public static void setStringOrNull(PreparedStatement ps, int index, String s) throws SQLException {
29 | if (s==null) {
30 | ps.setNull(index, Types.VARCHAR);
31 | } else {
32 | ps.setString(index, s);
33 | }
34 | }
35 |
36 | public static void setIntOrNull(PreparedStatement ps, int index, Integer i) throws SQLException {
37 | if (i==null) {
38 | ps.setNull(index, Types.INTEGER);
39 | } else {
40 | ps.setInt(index, i);
41 | }
42 | }
43 |
44 | public static void setIntPositiveOrNull(PreparedStatement ps, int index, int i) throws SQLException {
45 | if (i<=0) {
46 | ps.setNull(index, Types.INTEGER);
47 | } else {
48 | ps.setInt(index, i);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/processor/src/main/resources/templates/ServiceFactory.vm:
--------------------------------------------------------------------------------
1 | /*** GENERATED FROM ${info.inputFile} - DO NOT EDIT ***/
2 |
3 | /*
4 | * ${className}.java
5 | */
6 | package ${info.packageName};
7 |
8 | import com.rhythm.louie.ServiceProvider;
9 | import com.rhythm.louie.server.ServiceProperties;
10 | import com.rhythm.louie.service.ServiceFactory;
11 | import com.rhythm.louie.service.ServiceUtils;
12 |
13 | @ServiceProvider
14 | public class ${className} implements ServiceFactory {
15 |
16 | private static final String serviceName = "${info.serviceName}";
17 |
18 | public ${className}() {}
19 |
20 | @Deprecated
21 | public static ${className} getInstance() {
22 | return new ${className}();
23 | }
24 |
25 | @Override
26 | public String getServiceName() {
27 | return serviceName;
28 | }
29 |
30 | public static ${info.serviceClassName} getServiceClient() throws Exception {
31 | return loadService().getDelegate();
32 | }
33 |
34 | private static ${baseName}ServiceHandler service;
35 |
36 | @Override
37 | public ${baseName}ServiceHandler getService() throws Exception {
38 | return loadService();
39 | }
40 |
41 | @SuppressWarnings("unchecked")
42 | private static synchronized ${baseName}ServiceHandler loadService() throws Exception {
43 | if (service!=null) {
44 | return service;
45 | }
46 |
47 | ServiceProperties props = ServiceProperties.getServiceProperties(serviceName);
48 |
49 | ${info.serviceClassName} serviceImpl = ServiceUtils.loadService(props.getServiceLayers(),${info.serviceClassName}.class);
50 |
51 | service = new ${baseName}ServiceHandler();
52 | service.setDelegate(serviceImpl);
53 | return service;
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/cache/LoadingSupplier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.rhythm.louie.cache;
18 |
19 | import com.google.common.base.Supplier;
20 |
21 | import org.slf4j.LoggerFactory;
22 |
23 | /**
24 | * A supplier that is able to deal with loading operations that throw exceptions.
25 | * In the event that load() throws an exception, the previous value retrieved is returned.
26 | *
27 | * @param
28 | */
29 | public abstract class LoadingSupplier implements Supplier {
30 |
31 | private T previous = null;
32 |
33 | @Override
34 | public final T get() {
35 | try {
36 | previous = load();
37 | } catch (Exception e) {
38 | LoggerFactory.getLogger(LoadingSupplier.class).error("Error looking up supplier value!", e);
39 | }
40 | return previous;
41 | }
42 |
43 | /**
44 | * Load an instance of the appropriate type. May throw an exception that will be
45 | * swallowed in the get().
46 | *
47 | * @return the loaded value
48 | * @throws Exception if there was a problem loading the type.
49 | */
50 | abstract public T load() throws Exception;
51 | }
52 |
--------------------------------------------------------------------------------
/web/src/main/resources/templates/servers.vm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Louie(${contextPath}) - Servers
5 |
6 | #parse("templates/header.vm")
7 |
8 |
9 |
10 |
11 | #parse("templates/navbar.vm")
12 |
13 |
14 |
15 |
16 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
Louie Deployment Network
31 |
32 |
33 | #foreach($server in $servers)
34 |
35 |
36 |
37 |
38 | #if($server.isSecure())
39 |
40 | #else
41 |
42 | #end
43 |
44 |
45 |
46 | ${server.printHtmlServer()}
47 |
48 |
49 |
50 |
51 | #end
52 |
53 |
54 |
55 |
56 | #parse("templates/footer.vm")
57 |
58 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/request/LogVars.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.request;
17 |
18 | /**
19 | * @author cjohnson
20 | * Created: Jun 14, 2011 5:34:45 PM
21 | */
22 | public class LogVars {
23 |
24 | public static final String IP = "ip";
25 | public static final String SESSION = "session";
26 | public static final String TIME = "time";
27 | public static final String EXECTIME = "exectime";
28 | public static final String BYTES = "bytes";
29 | public static final String ROWS = "rows";
30 | public static final String RETURN = "return";
31 | public static final String REQID = "reqid";
32 | public static final String MODULE = "module";
33 | public static final String LANGUAGE = "language";
34 |
35 | // Used By Auth Logs
36 | public static final String USER = "user";
37 | public static final String PROGRAM = "program";
38 | public static final String LOCATION = "location";
39 | public static final String MACHINE = "machine";
40 | public static final String PATH = "path";
41 | public static final String PROCESSID = "processId";
42 | }
43 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/util/Lists.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.util;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | *
22 | * @author cjohnson
23 | */
24 | public class Lists {
25 | private Lists() {}
26 |
27 | /**
28 | * Merges 2 lists as efficiently as possible. If either argument is null or empty,
29 | * the other is returned, favoring the first if both are.
30 | *
31 | * If both are non-empty, then the second list is added to the first and the first is returned.
32 | *
33 | * @param
34 | * @param first
35 | * @param second
36 | * @return returns either the first list or the second list, possibly modifying the first
37 | */
38 | public static List mutableMerge(List first, List second) {
39 | if (first == null || first.isEmpty()) {
40 | if (second != null && !second.isEmpty()) {
41 | return second;
42 | } else {
43 | return first;
44 | }
45 | } else if (second == null || second.isEmpty()) {
46 | return first;
47 | } else {
48 | first.addAll(second);
49 | return first;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/jms/MessageInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.jms;
17 |
18 | import com.rhythm.louie.jms.JmsProtos.*;
19 |
20 | /**
21 | *
22 | * @author cjohnson
23 | */
24 | public class MessageInfo {
25 | private final MessageBPB bundle;
26 | private final MessageAction action;
27 | private int contextIndex = -1;
28 |
29 | public MessageInfo(MessageBPB bundle) {
30 | this.bundle = bundle;
31 | action = MessageAction.typeFromAction(bundle.getAction());
32 | }
33 |
34 | public MessageBPB getBundle() {
35 | return bundle;
36 | }
37 |
38 | public MessageAction getAction() {
39 | return action;
40 | }
41 |
42 | public int getContentCount() {
43 | return bundle.getContentCount();
44 | }
45 |
46 | public int getContentIndex() {
47 | return contextIndex;
48 | }
49 |
50 | public boolean hasMoreContent() {
51 | return bundle.getContentCount()>(contextIndex+1);
52 | }
53 |
54 | public ContentPB getNextContent() throws Exception {
55 | return bundle.getContent(++contextIndex);
56 | }
57 |
58 | public ContentPB getCurrentContent() throws Exception {
59 | return bundle.getContent(contextIndex);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/connection/BasicSSLClientConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.connection;
17 |
18 | /**
19 | *
20 | * @author eyasukoc
21 | */
22 | public class BasicSSLClientConfig extends SSLClientConfig implements SSLConfig{
23 |
24 | private String gateway,clientCert,caKeystore;
25 | private int port;
26 |
27 | public BasicSSLClientConfig(String host) {
28 | setHost(host);
29 | }
30 |
31 | public void setPort(int port) {
32 | this.port = port;
33 | }
34 |
35 | @Override
36 | public int getPort() {
37 | return port;
38 | }
39 |
40 | public void setGateway(String gateway) {
41 | this.gateway = gateway;
42 | }
43 |
44 | @Override
45 | public String getGateway() {
46 | return gateway;
47 | }
48 |
49 | public void setClientCertificate(String certificatePath) {
50 | this.clientCert = certificatePath;
51 | }
52 |
53 | @Override
54 | public String getClientCertificate() {
55 | return clientCert;
56 | }
57 |
58 | public void setCAKeyStore(String keystorePath) {
59 | this.caKeystore = keystorePath;
60 | }
61 |
62 | @Override
63 | public String getCAKeystore() {
64 | return caKeystore;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/server/LocalConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.server;
17 |
18 | import java.net.InetAddress;
19 | import java.net.UnknownHostException;
20 |
21 | import org.slf4j.LoggerFactory;
22 |
23 | /**
24 | * @author cjohnson
25 | * Created: Jul 21, 2011 5:39:57 PM
26 | */
27 | public class LocalConstants {
28 | public static final String HOST;
29 | public static final String HOSTDOMAIN;
30 | public static final String DOMAIN;
31 | public static final String IP;
32 |
33 | static {
34 | String host = "";
35 | String hostdomain = "";
36 | String domain = "";
37 | String address = "";
38 | try {
39 | host = InetAddress.getLocalHost().getHostName();
40 | String[] components = host.split("\\.");
41 | host = components[0];
42 | InetAddress me = InetAddress.getLocalHost();
43 | hostdomain = me.getCanonicalHostName();
44 | address = me.getHostAddress();
45 | domain = hostdomain.replaceFirst(".*?\\.", "");
46 | } catch (UnknownHostException ex) {
47 | LoggerFactory.getLogger(LocalConstants.class).error("Error initializing local host constants!", ex);
48 | }
49 | HOST=host;
50 | HOSTDOMAIN=hostdomain;
51 | DOMAIN=domain;
52 | IP = address;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/client/connection/JsonReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.client.connection;
17 |
18 | import java.io.BufferedReader;
19 |
20 | /**
21 | * @author cjohnson
22 | * Created: Jun 13, 2011 3:18:34 PM
23 | */
24 | public class JsonReader {
25 | private BufferedReader reader;
26 |
27 | public JsonReader(BufferedReader reader) {
28 | this.reader = reader;
29 | }
30 |
31 | public String readJson() throws Exception {
32 | int i = reader.read();
33 | char b = (char) i;
34 |
35 | if (i==-1) {
36 | return null;
37 | } else if (b!='{') {
38 | throw new Exception("JSON Parse Exception, Missing \"{\"!\n");
39 | }
40 | StringBuilder sb = new StringBuilder();
41 | sb.append(b);
42 |
43 | int level=1;
44 | while (level>0) {
45 | i = reader.read();
46 |
47 | if (i==-1) {
48 | throw new Exception("JSON Parse Exception, EOF reached unexpectedly\n");
49 | }
50 |
51 | b = (char) i;
52 | if (b=='{') {
53 | level++;
54 | } else if (b=='}') {
55 | level--;
56 | }
57 | sb.append(b);
58 | }
59 | String json = sb.toString();
60 | return json;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/site/apt/manual/develop/service.apt:
--------------------------------------------------------------------------------
1 | ------
2 | Writing a Service
3 | ------
4 |
5 | Writing a Service
6 |
7 | * Defining a Service
8 |
9 | A Louie service is defined by simply tagging an interface with the @Service annotation. This flags the service for processing by the Louie annotation processor. Below is the example service generated by the Louie archetype.
10 |
11 | +-------+
12 | @Service
13 | public interface SampleService {
14 | /**
15 | * An example service method which accepts a String
16 | * and returns a SampleResponsePB
17 | *
18 | * @param request
19 | * @return SampleResponsePB
20 | * @throws Exception
21 | */
22 | SampleResponsePB basicRequest(String request) throws Exception;
23 | }
24 | +-------+
25 |
26 | When defining services keep in mind the following rules:
27 |
28 | * The names of parameters must not be reserved words in a programming language (mainly just java,c,python,perl). The Louie compiler has a list of reserved words that it will prevent you from using one accidentally. The reason for this is how clients will be autogenerated in various languages.
29 |
30 | * The arguments to a service method must be:
31 | * Protocol Buffer object (ie Message)
32 | * Standard java Object (String,Integer,Long,Float,Double,Date,Boolean)
33 | * List of a standard java datatype, ie List
34 | * Lists of Protocol Buffers are not yet supported
35 |
36 | * The return type must be:
37 | * Protocol Buffer objects (ie Message)
38 | * Standard java datatype (String,Integer,Long,Float,Double,Date,Boolean)
39 | * List of a standard java datatype, ie List
40 | * List of a Protocul Buffer, ie List
41 |
42 | * Javadoc is optional, but encouraged. The javadoc comments section will propagate to client apis in the various languages. Therefore the docs should be as language agnostic as possible.
43 |
44 |
45 | * Service Method Tags
46 |
47 | Need some descriptions here...
48 |
49 | * Grouping
50 |
51 | * Updating
52 |
53 | * Internal
54 |
55 | * Disabled
56 |
57 | * Streaming
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/services/info/InfoService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.services.info;
17 |
18 | import java.util.List;
19 |
20 | import com.rhythm.louie.Service;
21 |
22 | import com.rhythm.louie.info.InfoProtos.*;
23 |
24 | /**
25 | *
26 | * @author cjohnson
27 | */
28 | @Service
29 | public interface InfoService {
30 | public static final String SERVICE_NAME = "info";
31 |
32 | /**
33 | * Returns the names of all services
34 | *
35 | * @return
36 | * @throws Exception
37 | */
38 | List getAllServiceNames() throws Exception;
39 |
40 | /**
41 | * Returns info for all services
42 | *
43 | * @return
44 | * @throws Exception
45 | */
46 | List getAllServices() throws Exception;
47 |
48 | /**
49 | * Returns info for a single service
50 | *
51 | * @param name
52 | * @return
53 | * @throws Exception
54 | */
55 | ServicePB getService(String name) throws Exception;
56 |
57 | /**
58 | * Return a list of all unique locations in this server installation
59 | *
60 | * @return
61 | * @throws Exception
62 | */
63 | List getServerLocations() throws Exception;
64 |
65 | /**
66 | * Return all Servers in this installation
67 | *
68 | * @return
69 | * @throws Exception
70 | */
71 | List getServers() throws Exception;
72 | }
73 |
--------------------------------------------------------------------------------
/web/src/main/resources/templates/build.vm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Louie(${contextPath}) - Build
5 |
6 | #parse("templates/header.vm")
7 |
8 |
9 |
10 |
11 | #parse("templates/navbar.vm")
12 |
13 |
14 |
15 |
16 |
17 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
34 | #foreach($build in $builds)
35 | ${build.name}:${build.version} ${build.buildString}
36 | #end
37 |
38 |
39 |
40 |
41 |
42 |
45 | #foreach($build in $louieBuilds)
46 | ${build.name}:${build.version} ${build.buildString}
47 | #end
48 |
49 |
50 |
51 |
52 |
53 |
56 | #foreach($build in $otherBuilds)
57 | ${build.name}:${build.version} ${build.buildString}
58 | #end
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | #parse("templates/footer.vm")
67 |
68 |
69 |
--------------------------------------------------------------------------------
/engine/src/main/java/com/rhythm/louie/server/ThreadInspector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.server;
17 |
18 | import java.lang.management.ManagementFactory;
19 | import java.lang.management.ThreadInfo;
20 | import java.lang.management.ThreadMXBean;
21 |
22 | /**
23 | *
24 | * @author eyasukoc
25 | */
26 | public enum ThreadInspector {
27 |
28 | INSTANCE;
29 |
30 | ThreadMXBean threadBean;
31 |
32 | ThreadInspector() {
33 | threadBean = ManagementFactory.getThreadMXBean();
34 | }
35 |
36 | public long[] findDeadlockedThreads() {
37 | return threadBean.findDeadlockedThreads();
38 | }
39 |
40 | public long[] findMonitorDeadlockedThreads() {
41 | return threadBean.findMonitorDeadlockedThreads();
42 | }
43 |
44 | public ThreadInfo getThreadInfo(long id) {
45 | return threadBean.getThreadInfo(id);
46 | }
47 |
48 | public ThreadInfo getThreadInfo(long id, int maxDepth) {
49 | return threadBean.getThreadInfo(id, maxDepth);
50 | }
51 |
52 | public String dumpStack(long id, int maxDepth) {
53 | ThreadInfo info= threadBean.getThreadInfo(id,maxDepth);
54 | StackTraceElement[] trace = info.getStackTrace();
55 | StringBuilder builder = new StringBuilder();
56 | for (StackTraceElement elem : trace) {
57 | builder.append(elem).append("\n");
58 | }
59 | return builder.toString();
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/engine/src/test/java/com/rhythm/louie/services/devtest/DevTestServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Rhythm & Hues Studios.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rhythm.louie.services.devtest;
17 |
18 | import org.junit.BeforeClass;
19 | import org.junit.Test;
20 |
21 | import com.rhythm.louie.connection.Identity;
22 | import com.rhythm.louie.connection.LouieConnection;
23 | import com.rhythm.louie.connection.LouieConnectionFactory;
24 |
25 | import static org.junit.Assert.*;
26 |
27 | /**
28 | *
29 | * @author cjohnson
30 | */
31 | public class DevTestServiceTest {
32 |
33 |
34 | private static DevTestServiceClient client;
35 | public DevTestServiceTest() {}
36 |
37 | @BeforeClass
38 | public static void setUpClass() throws Exception {
39 | LouieConnection conn = LouieConnectionFactory.getConnection("localhost",
40 | Identity.createJUnitIdentity());
41 |
42 | client = DevTestClientFactory.getClient(conn);
43 | }
44 |
45 |
46 | @Test
47 | public void messageFeedbackTest() throws Exception {
48 | String captured = client.messageTest("Test Message");
49 | System.out.println("Captured: " + captured);
50 | // captured = client.messageTest("test2");
51 | // System.out.println("Captured: " + captured);
52 | }
53 |
54 | @Test
55 | public void sendEmail() throws Exception {
56 | client.sendEmail("cjohnson@rhythm.com", "cjohnson@rhythm.com", "Testing email services", "Hello!");
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------