Skip to content

Commit c2f548d

Browse files
committed
Add a JNDI ObjectFactory for Datastore instances
1 parent 0cd6f98 commit c2f548d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2015 Google Inc. All Rights Reserved.
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.google.gcloud.spi;
18+
19+
import java.util.Hashtable;
20+
21+
import javax.naming.Context;
22+
import javax.naming.Name;
23+
import javax.naming.spi.ObjectFactory;
24+
25+
import com.google.gcloud.datastore.DatastoreFactory;
26+
import com.google.gcloud.datastore.DatastoreOptions;
27+
28+
/**
29+
* JNDI ObjectFactory for Datastore instances.
30+
*/
31+
public class DatastoreObjectFactory implements ObjectFactory {
32+
33+
@Override
34+
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
35+
// TODO: initialize options using values from tree.
36+
return DatastoreFactory.instance().get(DatastoreOptions.defaultInstance());
37+
}
38+
}

0 commit comments

Comments
 (0)